layui.use(['table','form','jquery','laypage'],function () {
    var form = layui.form,
        table = layui.table,
        page = layui.laypage,
        $ = layui.jquery;

    //资产设备
    var asset_data = table.render({
        elem: "#asset",
        url: '/assetController/list',
        cellMinWidth: 95,
        limit: 5,
        limits: [5, 10, 15, 20, 25],
        page: true,
        loading:true,
        response: {
            statusName: 'code'
            , statusCode: 200
            , msgName: 'msg'
            , countName: 'count'
            , dataName: 'data'
        },
        id: 'assetList',
        cols: [[
            {type: "checkbox", fixed: "left", width: 50},
            {field: 'id', title: 'ID', width: 60, align: "center"},
            {field: 'assetType', title: '设备资产类型',align:'center'},
            {field:'assetCount', title:'数量',width: 200,align:'center'}
            /*{title:'操作', width: 120, templet: '#assetToolBar', fixed: "right", align: "center"}*/
        ]]
    });


    //学校区域
    var area_data = table.render({
        elem: "#area",
        url: '/areaMapperController/list',
        cellMinWidth: 95,
        limit: 5,
        limits: [5, 10, 15, 20, 25],
        page: true,
        loading:true,
        response: {
            statusName: 'code'
            , statusCode: 200
            , msgName: 'msg'
            , countName: 'count'
            , dataName: 'data'
        },
        id: 'userList',
        cols: [[
            {type: "checkbox", fixed: "left", width: 50},
            {field: 'id', title: 'ID', width: 60, align: "center"},
            {field: 'areaName', title: '区域名称', align: 'center'},
           /* {title:'操作', width: 120, templet: '#areaToolBar', fixed: "right", align: "center"}*/
        ]]
    });

    //维修人员负责的区域
    var unit_data = table.render({
        elem: "#unit",
        url: '/unitController/list',
        cellMinWidth: 95,
        limit: 5,
        limits: [5, 10, 15, 20, 25],
        page: true,
        loading:true,
        response: {
            statusName: 'code'
            , statusCode: 200
            , msgName: 'msg'
            , countName: 'count'
            , dataName: 'data'
        },
        id: 'unitList',
        cols: [[
            {type: "checkbox", fixed: "left", width: 50},
            {field: 'id',title: 'ID', width: 60, align: "center"},
            {field: 'location', title: '负责区域名称', align: 'center'},
            {field:'serviceName', title:'区域维修负责人'},
           /* {title: '操作', width: 120, templet: '#unitToolBar', fixed: "right", align: "center"}*/
        ]]
    });

    /**
     * 弹出添加窗口 添加区域
     */
    $('.addArea').click(function () {
        var index = layer.open({
            title:"添加区域",
            type:2,
            area:['25%','35%'],
            content:'./add_area.html',
            success: function (layero, index) {//参数绑定
                setTimeout(function(){
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                },500)
            }

        });
        //窗口大小改变时，重置宽高
        $(window).on("resize",function(){
            layer.area = ['25%','30%']
        })
    });




    /**
     * 弹出添加窗口  添加维修人员
     */
    $('.addUnit').click(function () {
        var index = layer.open({
            title:"添加区域负责人",
            type:2,
            area:['30%','40%'],
            content:'./add_unit.html',
            success: function (layero, index) {//参数绑定
                setTimeout(function(){
                    layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                        tips: 3
                    });
                },500)
            }

        })
        //窗口大小改变时，重置宽高
        $(window).on("resize",function(){
            layer.area = ['30%','40%']
        })
    });



});
